<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>race-方法</title>
</head>
<body>
<script>
  // race-方法  返回的是最先到达的状态(无论成功还是失败)

  let promise1=new Promise((resolve, reject) => {
    setTimeout(()=>{
      resolve('ok')
    },2000)
  })
  let promise2=new Promise((resolve, reject) => {
    setTimeout(()=>{
      resolve('success')
    },1000)
  })
  let promise3=new Promise((resolve, reject) => {
    setTimeout(()=>{
      reject('error')
    },3000)
  })

  let result=Promise.race([promise1,promise2,promise3])
  console.log(result)
</script>
</body>
</html>